/* ptsdd.t   BOM STRUCTURE SUBSTITUTE PUR PCT DELETE TRIGGER                 */

	TRIGGER PROCEDURE FOR DELETE OF grd_det.

    {mfdeclre.i }
    define new shared work-table wf_old_grd_det like grd_det.

	HK:
	do:
        if can-find(first dt_mstr where dt_table = "grd_det" and dt_type = "SYNC") then
            run CreateSyncFlag(input "DEL", input recid(grd_det), input "grd_det").

        if not can-find ( first dt_mstr where dt_table = "grd_det" and dt_type = "DEL" ) then leave HK.
        
        if not can-find ( first wf_old_grd_det ) then do:
            create wf_old_grd_det.
            if recid(wf_old_grd_det)= -1 then .
        end.
        
        buffer-copy grd_det to wf_old_grd_det no-error.

        for first dt_mstr no-lock where dt_table = "grd_det" and dt_type = "DEL" :
        
    	    run CreateDthist(input dt_table, input dt_field, input dt_type, input "", input "", 
                input recid(grd_det), input grd_det.grd_id, input string(grd_det.grd_group), input string(grd_det.grd_number), input grd_det.grd_part,
        	    input grd_det.grd_sub_part, input "", input "", input "") .
			
        end.
   end.

{hkdttrans.i}
